package delegated_property

import kotlin.properties.Delegates


//vetoable代理 监听修改的值并确定是否修改
fun main(args: Array<String>) {
    val vetoableUser = VetoableUser()
    vetoableUser.name = 2
    println("vetoableUser1 ${vetoableUser.name}")

    vetoableUser.name = 1
    println("vetoableUser2 ${vetoableUser.name}")
}

class VetoableUser{
    var name : Int by Delegates.vetoable(1){
        d,old,new->
        println("$old - $new")
        old <= new
    }

}


